package lanou.autohome.basetool;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

/**
 * Created by dllo on 16/8/15.
 */
public class SingleQueue {
    private static SingleQueue singleQueue;
    private RequestQueue mrequestQueue;

    //构造方法私有化
    private SingleQueue(){
        //对请求赋值
        //使用APP的context,来避免内存泄漏
        mrequestQueue = Volley.newRequestQueue(MyApp.getContext());
    }

    //入口方法,获取单例的唯一的方法
    public static SingleQueue getInstance(){
        //保证效率
        if(singleQueue == null){
            synchronized (SingleQueue.class){
                //初始化,只有一个对象
                if(singleQueue == null){
                    singleQueue = new SingleQueue();
                }
            }
        }
        return  singleQueue;
    }

    public void addRequest(Request request){
        mrequestQueue.add(request);
    }

}
